﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuickORM.BLL;
using QuickORM.Entity;
using QuickORM.Common;
using Lir.Pager.Entity;
public partial class Manage_WebPages_UserInfo_RoleList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Query("");
        }
    }
    #region 检索
    /// <summary>
    /// 检索
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="eventArgs"></param>
    protected void btnSelect_Click(object sender,EventArgs eventArgs)
    {
        string name = Util.querySQL(txtRoleName.Value.Trim());
        Query(name);
        ViewState["name"] = name;
    }
    #endregion
    #region 分页处理
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        Query(ViewState["name"]!=null?ViewState["name"].ToString():"");
    }
    #endregion
    #region 查询方法
    /// <summary>
    /// 检索条件
    /// </summary>
    /// <param name="name"></param>
    protected void Query(string name)
    {
        
        PagerInfo pager = new PagerInfo();
        pager.CurrenetPageIndex = AspNetPager1.CurrentPageIndex;
        pager.PageSize = AspNetPager1.PageSize;
        rptList.DataSource = BLLFactory<T_RoleManager>.Instance.FindWithPager(string.Format("RoleName like '%{0}%'", name), pager, "RoleID", true);
        rptList.DataBind();
        AspNetPager1.RecordCount = pager.RecordCount;
    }
    #endregion
    #region 删除
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void linkBtnDel_Click(object sender, EventArgs e)
    {
        LinkButton linkBtnDel = sender as LinkButton;
        if (linkBtnDel.CommandName == "del")
        {
            int id = Convert.ToInt32(linkBtnDel.CommandArgument);
            BLLFactory<T_RoleManager>.Instance.Delete(id);
            Query(ViewState["name"] != null ? ViewState["name"].ToString() : "");
        }
    }
    #endregion

}